package com.jfunit.example.controller;

import com.jfunit.java.annotation.Action;
import com.jfunit.java.annotation.Controller;
import com.jfunit.java.annotation.Inject;
import com.jfunit.java.annotation.PathVariable;
import com.jfunit.java.annotation.RequestParam;
import com.jfunit.java.annotation.ResponseBody;
import com.jfunit.java.bean.View;
import com.jfunit.java.mvc.DataContext;
import com.jfunit.example.service.UserService;


@Controller
public class IndexController {

    @Inject
    private UserService userService;
    
    @Action(method="get",value="/index")
    public View index(){
        System.out.println(111);
        userService.getUserList();
        return new View("index.jsp");
    }
    
    @Action(method="get",value="/index/{id}/{dd}")
    public View index2(long id,String a){
        System.out.println("+++++++++++++++++++++++++");
        System.out.println(id);
        System.out.println(a);
        System.out.println(DataContext.Request.getAll());
        
        String  param = DataContext.getRequest().getQueryString();
        
        System.out.println("param:" + param);
        System.out.println(DataContext.getRequest().getParameter("a"));
        System.out.println(DataContext.Request.getParameter("cc").toString());
        return new View("index.jsp");
    }
    
    @Action(method="post",value="/index/{id}/{dd}")
    @ResponseBody
    public View index3(@PathVariable("id")Long idddd,@RequestParam(value="errMsg") String errMsg){
        System.out.println("+++++++++++++++++++++++++");
        System.out.println("idddd:"+idddd);
        System.out.println("errMsg:"+errMsg);
        
        /*System.out.println(DataContext.Request.getAll());
        
        String  param = DataContext.getRequest().getQueryString();
        
        System.out.println("param:" + param);
        System.out.println(DataContext.getRequest().getParameter("a"));
        System.out.println(DataContext.Request.getParameter("cc"));
        System.out.println(DataContext.Request.getAllParameter());*/
        return new View("index.jsp");
    }
}
